export const methods = {
    async createPrefab(fileName:string,className:string,prefabUrl:string){

        const {Node,js,Layers,UITransform} = require("cc");
        const node  = new Node(fileName);
        node.layer = Layers.Enum.UI_2D;
        node.addComponent(UITransform);

        while(true){
            const result  = js.getClassByName(className);
            if (result) {
                break;
            }
            await new Promise((next)=>{
                setTimeout(next,1000);
            })
        }

        const com = node.addComponent(className);
        com.resetInEditor && com.resetInEditor();

        const info = cce.Prefab.generatePrefabDataFromNode(node) as any;
        
        node.destroy();

        return Editor.Message.request("asset-db","create-asset",prefabUrl,info.prefabData || info);
    }
};